

public class Dinucleotide {
	
	/* 
	 * Class representing dinucleotids => 2 letter of {A,C,G,T}
	 */
	
	// Attributes
	
	public char left;
	public char right;
	
	// Constructors
	
	public Dinucleotide(char _left, char _right)
	{
		this.left  = _left;
		this.right = _right;
	}
	
	// Convert a Dinucleotid into a string
	public String toString()
	{
		return "" + this.left + this.right;
	}
	
	// Complementarity of a letter
	private char _complementarity(char a)
	{
		switch (a)
		{
			case 'A':
				return 'T';
			
			case 'C' :
				return 'G';
			
			case 'G' :
				return 'C';
			
			case 'T' :
				return 'A';
		}
		
		return '?';
	}
	
	// Complementarity of a Dinucleotid
	public Dinucleotide complementarity()
	{
		return new Dinucleotide(_complementarity(this.right),_complementarity(this.left));
	}
	
	// Permutation of a Dinucleotid
	public Dinucleotide permutation()
	{
		return new Dinucleotide(this.right,this.left);
	}
	
	// Others
	
	// Redefinition of the equality between two Dinucleotids
	public boolean equals(Object o)
	{
		Dinucleotide d = (Dinucleotide) o; 
		return (this.left  == d.left &&
				this.right == d.right);
	}
}